package com.dk.controller;


import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import com.dk.pojo.LimitedSpecial;
import com.dk.pojo.LimitedSpecialVO;
import com.dk.service.LimitedSpecialService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 帅杰
 * @since 2021-08-12 跳楼秒杀
 */
@RestController
@RequestMapping("limitedSpecial")
public class LimitedSpecialController {

    @Autowired
    private LimitedSpecialService limitedSpecialService;


    @PostMapping
    @ApiOperation(value = "新增")
    //当用户把自己要卖的车辆申请加入秒杀 我们把用户对应的车辆信息,去数据库中更新一个状态
    public Result toInsert(@RequestBody LimitedSpecial limitedSpecial){
            limitedSpecialService.toInsert(limitedSpecial);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //我们通过申请更改的商品状态加入秒杀列表 在秒杀模块内展示出来
    @GetMapping("{messageId}")
    @ApiOperation(value = "多表查询")
    public Result toSelect(@PathVariable("messageId")Long messageId){
        List<LimitedSpecialVO> specialVOList =limitedSpecialService.toSelect(messageId);
        return Result.buildResult(ResultEnum.SUCCESS).setData(specialVOList);
    }


}

